/**
 * @param {string} s
 * @return {boolean}
 */
 var isValid = function(s) {
  if(s.length % 2 !== 0){
      return false;
  }
  let stack = [];
  for(let i = 0; i < s.length ; i++ ){
      const character = s[i];
      if(character === "(" || character === "[" || character === "{" ){
          stack.push(character);
      }else{
          const top = stack[stack.length - 1];
          if( (top === "(" && character ===")") ||
              (top === "[" && character ==="]") ||
              (top === "{" && character ==="}")
           ){
              stack.pop();
          }else{
              return false;
          }
      }
  }
  return stack.length === 0;
};